class PaneRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;
	Point2i TextureOffset, SideOffset;
	
	PaneRenderer(ITexture *texture, const Point2i &offset, const Point2i &sideOffset) :
		Texture(texture),
		TextureOffset(offset),
		SideOffset(sideOffset)
	{
	}

	PaneRenderer(ITexture *texture, const Point2i &offset) :
		Texture(texture),
		TextureOffset(offset),
		SideOffset(offset)
	{
	}

	int GetTypeData(const int &data) { return data; }

	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		auto &north = schematic->GetBlock(position.X, position.Y, position.Z + 1);
		auto &south = schematic->GetBlock(position.X, position.Y, position.Z - 1);
		auto &east = schematic->GetBlock(position.X + 1, position.Y, position.Z);
		auto &west = schematic->GetBlock(position.X - 1, position.Y, position.Z);

		bool hasNorth = (north != Block::Empty);
		bool hasSouth = (south != Block::Empty);
		bool hasEast = (east != Block::Empty);
		bool hasWest = (west != Block::Empty);

		bool allMissing = !(hasNorth || hasSouth || hasEast || hasWest);

		if (allMissing)
			hasNorth = hasSouth = hasEast = hasWest = true;
		
		if (hasNorth)
		{
			renderer->Draw(Face(Point3f(8, 0, 8), Point3f(8, 0, 16), Point3f(8, 16, 16), Point3f(8, 16, 8), Colorb::White, Texture, SideOffset + Point2i(8, 0), 8, 16), true);
			renderer->Draw(Face(Point3f(7, 0, 8), Point3f(9, 0, 8), Point3f(9, 0, 16), Point3f(7, 0, 16), Colorb::White, Texture, TextureOffset + Point2i(7, 8), 2, 8), true);
		}
		
		if (hasSouth)
		{
			renderer->Draw(Face(Point3f(8, 0, 0), Point3f(8, 0, 8), Point3f(8, 16, 8), Point3f(8, 16, 0), Colorb::White, Texture, SideOffset, 8, 16), true);
			renderer->Draw(Face(Point3f(7, 0, 0), Point3f(9, 0, 0), Point3f(9, 0, 8), Point3f(7, 0, 8), Colorb::White, Texture, TextureOffset + Point2i(7, 0), 2, 8), true);
		}
		
		renderer->Translate(8, 8, 8);
		renderer->Rotate(90, 0, 1, 0);
		renderer->Translate(-8, -8, -8);

		if (hasEast)
		{
			renderer->Draw(Face(Point3f(8, 0, 8), Point3f(8, 0, 16), Point3f(8, 16, 16), Point3f(8, 16, 8), Colorb::White, Texture, SideOffset + Point2i(8, 0), 8, 16), true);
			renderer->Draw(Face(Point3f(7, 0, 8), Point3f(9, 0, 8), Point3f(9, 0, 16), Point3f(7, 0, 16), Colorb::White, Texture, TextureOffset + Point2i(7, 8), 2, 8), true);
		}
		
		if (hasWest)
		{
			renderer->Draw(Face(Point3f(8, 0, 0), Point3f(8, 0, 8), Point3f(8, 16, 8), Point3f(8, 16, 0), Colorb::White, Texture, SideOffset, 8, 16), true);
			renderer->Draw(Face(Point3f(7, 0, 0), Point3f(9, 0, 0), Point3f(9, 0, 8), Point3f(7, 0, 8), Colorb::White, Texture, TextureOffset + Point2i(7, 0), 2, 8), true);
		}
	}
};